package com.zw.yzk.kabu.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.alibaba.android.vlayout.layout.SingleLayoutHelper;
import com.zw.yzk.kabu.R;

/**
 * Created by skydar on 2017/4/13.
 */

public class SkinCategorySubjectListAdapter extends DelegateAdapter.Adapter<SkinCategorySubjectListAdapter.Holder> {

    private Context context;
    private LayoutHelper layoutHelper;
    private String category = "";

    public SkinCategorySubjectListAdapter(String category) {
        SingleLayoutHelper helper = new SingleLayoutHelper();
        helper.setBgColor(R.color.white);
        this.layoutHelper = helper;
        this.category = category;
    }

    @Override
    public LayoutHelper onCreateLayoutHelper() {
        return layoutHelper;
    }

    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
        if (context == null) {
            context = parent.getContext();
        }
        return new Holder(LayoutInflater.from(context).inflate(R.layout.recycler_item_skin_category_subject_list, parent, false));
    }

    @Override
    public void onBindViewHolder(Holder holder, int position) {
        holder.tv1.setText(category);
    }

    @Override
    public int getItemCount() {
        return 1;
    }


    static class Holder extends RecyclerView.ViewHolder {
        public TextView tv1;
        public Holder(View itemView) {
            super(itemView);
            tv1 = (TextView) itemView.findViewById(R.id.tv_category_subject);
        }
    }
}